<template>
  <div class="home">
    <el-row class="header_top">
      <el-col :span="12" class="height_gao">
        <div class="grid-content bg-purple  height_gao">
          <el-button type="success" class="subang" @click="drawing(1)" plain>审核提款</el-button>
          <el-button type="warning" class="subang" @click="drawing(2)" plain>驳回提款</el-button>
        </div>
      </el-col>
      <el-col :span="12" class="height_gao">
        <div class="grid-content bg-purple-light height_gao">
          <!--<el-button type="success" class="allith2" @click="export2Excel">-->
            <!--导出提款信息-->
          <!--</el-button>-->
        </div>
      </el-col>
    </el-row>

    <div class="autd animated slideInRight">
      <el-table :data="datatitle" border style="width: 100%" v-loading="loading2" element-loading-text="拼命加载中"
                @selection-change="handleSelectionChange">
        <el-table-column
          type="selection"
          width="55">
        </el-table-column>
        <el-table-column prop="user.nickname" label="用户昵称" width="130">
        </el-table-column>
        <el-table-column prop="user.phone" label="用户电话" width="130">
        </el-table-column>
        <el-table-column prop="money" label="提款总金额" width="100">
        </el-table-column>
        <el-table-column prop="remark" label="用户提交备注信息" width="330">
        </el-table-column>
        <el-table-column prop="created_at" label="提款发起时间" width="180">
        </el-table-column>
      </el-table>
      <el-pagination
        @current-change="handleCurrentChange"
        :current-page="cur"
        :page-size="pagesize"
        :page-count="currentPage4"
        layout="total, prev, pager, next" :total="total">
      </el-pagination>
    </div>
    <el-dialog title="驳回提款" :visible.sync="dialogFormVisible">
      <el-form>
        <el-form-item label="驳回提款备注信息:" :label-width="formLabelWidth">
         <textarea class="text_ares" v-model="express" placeholder="请填写驳回提款备注原因">
        </textarea>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="reject">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog
      title="提示"
      :visible.sync="adoptMoney"
      width="30%">
      <span>是否确定通过审核？</span>
      <span slot="footer" class="dialog-footer">
    <el-button @click="adoptMoney = false">取 消</el-button>
    <el-button type="primary" @click="adoptDrawing">确 定</el-button>
  </span>
    </el-dialog>


  </div>
</template>
<script>
  import  img from  "~/timg.jpg";
  export default {
    components: {},
    data(){
      return {
        img,
        urlimg: this.$IMG,
        salesman: '',//业务员
        pagesize: this.$store.state.attribute.page, //每页条数
        total: 1, //总条数
        currentPage4: 1, //总页数
        cur: 1, //当前页数
        loading2: true,
        Temporary: [],  //总数据
        datatitle: [],  //当页数据
        value4: '',
        Seeclass: [],
        fenleiflag: 1,
        imgarr: {},
        imgtext: "",
        rowindex: '',
        dialogFormVisible: false,
        formLabelWidth: '146px',
        express: '',//快递编号
        orderinfo: {},//订单信息
        orderIndex: 0,//订单位置
        Ordertype: 2,
        adoptMoney: false, //
        money_id: [],// 装提款ID
      }
    },
    methods: {

      drawing(e){       //批量提款审核
        if (this.money_id == []) {
          this.$notify({
            title: '警告',
            message: '请选择操作的用户',
            type: 'warning'
          });
        }else{
          switch (e) {
            case 1:    //通过
              this.adoptMoney = true;
              break;
            case 2:  //驳回
              this.dialogFormVisible = true;
              break;
          }
        }

      },
      adoptDrawing(){  //确认提款
        this.http.post({
          'api': 'admineditdrawings',
          'data': {
            'data': {
              "ids": this.money_id,
            }
          },
        }).then((res) => {
          if (res.data.status_code == 200) {
            this.$h.dataSuccess(res.data, this);
            this.adoptMoney = false;
            this.bodyaudh();
          }
        }, (err) => {
          if (err) {
            this.$h.Ed(err, this);
          }
        })
      },
      reject(){  //驳回提款
        this.http.post({
          'api': 'adminrejectdrawings',
          'data': {
            'data': {
              "ids": this.money_id,
              'remark': this.express
            }
          },
        }).then((res) => {
          if (res.data.status_code == 200) {
            this.$h.dataSuccess(res.data, this);
            this.dialogFormVisible = false;
            this.bodyaudh();
          }
        }, (err) => {
          if (err) {
            this.$h.Ed(err, this);
          }
        })
      },
      handleSelectionChange(val) {
        this.money_id = [];
        val.forEach((item) => {
          this.money_id.push(item.id);
        });

      },
//      export2Excel(){   //导出execl
//        var myDate = new Date();
//        let header = ['用户昵称', '用户电话', '提款总金额', '用户提交备注信息', '提款发起时间'];
//        let val = ['user.nickname', 'user.phone', 'money', 'remark', 'created_at'];
//        this.$h.exportexcel(header, val, this.datatitle, '商品信息' + myDate.toLocaleString());
//      },

      handleCurrentChange(val) { //分页
        if (this.fenleiflag != 1) {
          this.bodyaudh(val, this.Ordertype)
        }
      },
      bodyaudh(e) {
        this.loading2 = true;
        this.http.post({
          'api': 'admingetdrawings',
          'data': {
            'data': {
              "status": 1,
              "limit": this.pagesize,
            }
          },
          "page": e,
        }).then((res) => {
          this.shuju(res.data);
          this.fenleiflag = 0;
        }, (err) => {
          if (err) {
            this.$h.Ed(err, this);
          }
        })
      },
      shuju(data) {
        this.loading2 = false;
        this.total = data.total; //数据总的条数
        this.currentPage4 = data.last_page;
        this.datatitle = data.data;
      },
    },
    watch: {},
    computed: {
      //计算属性
    },
    mounted(){
      this.bodyaudh(1, 2);
      //生命周期
    }
  }
</script>
<style scoped>
  .home {
    width: 100%;
    height: 100%;
  }

  .img_ {
    width: 100%;
    height: 140px;
    background-size: 100% 100%;
    display: block;
  }

  .text_ares {
    width: 86%;
    height: 219px;
    margin-top: 11px;
  }

  .allith2 {
    background: #090404;
    float: right;
    /*margin-top: 15px;*/
  }

  .height_gao {
    height: 100%;
  }

  .header_top {
    height: 60px;
    width: 100%;
  }
</style>
